import 'dart:async';

import 'package:flutter_easyloading/flutter_easyloading.dart';

var _timer;

Future<void> showOk(String message) => EasyLoading.showSuccess(message);

Future<void> showFailed(String message) => EasyLoading.showError(message);

Future<void> showLoading(String message, {bool? cancelOnTouchOutside}) {
  _timer?.cancel();
  _timer = Timer.periodic(const Duration(seconds: 12), (timer) {
    hideLoading();
    timer.cancel();
  });
  return EasyLoading.show(status: message, dismissOnTap: cancelOnTouchOutside);
}

Future<void> hideLoading() => EasyLoading.dismiss();

Future<void> showProgress(double progress, {String? message}) =>
    EasyLoading.showProgress(progress, status: message);

Future<void> showToast(String message) => EasyLoading.showToast(message);
